---@diagnostic disable: undefined-global
--在没有安装packer的电脑上，自动安装packer插件
local fn = vim.fn
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
  --fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})	--默认地址
  fn.system({"git", "clone", "--depth", "1", "https://hub.fastgit.org/wbthomason/packer.nvim.git", install_path}) --csdn加速镜像
  vim.cmd "packadd packer.nvim"
end
-- Only required if you have packer configured as `opt`
vim.cmd [[packadd packer.nvim]]

return require("packer").startup(
  {
    function()
      use "wbthomason/packer.nvim"
      -- Packer can manage itself
      use {
        "vim-airline/vim-airline",
        requires = {
          "vim-airline/vim-airline-themes",
          --综合图标支持such vim-airline lightline, vim-startify
          "ryanoasis/vim-devicons"
        }
      }
      --内嵌浮动ranger插件
      use "kevinhwang91/rnvimr"
      -- 主题
      use "sainnhe/gruvbox-material"
      -- 文件搜索 预览 等
      -- use {
      --   "nvim-telescope/telescope.nvim",
      --   requires = {
      --     "nvim-lua/plenary.nvim",
      --     "kyazdani42/nvim-web-devicons"
      --   }
      -- }
      use {
        "Yggdroot/LeaderF",
        run = ":LeaderfInstallCExtension"
      }
      use "junegunn/fzf"
      use "https://gitee.com/mirrors/ripgrep.git"
      -- auto change root dir
      use "airblade/vim-rooter"
      -- 加速文件搜索速度,如果安装失败需要到插件目录执行make命令手动编译
      -- 用了这个插件以后，貌似更快了(感觉输入更跟手了，可能是心理作用)。但是对于我的小项目感受不是很明显
      -- use {"nvim-telescope/telescope-fzf-native.nvim", run = "make"}
      -- lazygit
      use "kdheepak/lazygit.nvim"
      -- Collection of configurations for built-in LSP client
      use {
        "neovim/nvim-lspconfig"
        -- requires = {
        --   -- 自动为尚不支持 Neovim 0.5 内置 lsp 客户端的配色方案创建缺少的 LSP 诊断突出显示组。
        --   "folke/lsp-colors.nvim",
        --   -- 基于neovim 内置lsp 的轻量级lsp 插件，具有高性能UI。非常酷
        --   "glepnir/lspsaga.nvim"
        -- }
      }
      use {
        "hrsh7th/nvim-cmp",
        requires = {
          "hrsh7th/cmp-nvim-lsp", -- neovim 内置lsp客户端的 nvim-cpp 源
          "onsails/lspkind-nvim", -- 美化自动完成提示信息
          "hrsh7th/cmp-buffer", -- 从 buffer 中智能提示
          "hrsh7th/cmp-nvim-lua", -- nvim-cmp source for neovim lua api
          "octaltree/cmp-look", -- 用于完成英语单词
          "hrsh7th/cmp-path", -- 自动提示硬盘上的文件
          "hrsh7th/cmp-cmdline" --
        }
      }
      -- formatter
      use "mhartington/formatter.nvim"
      -- bullet markdown sort
      use "dkarter/bullets.vim"
      -- markdown 预览插件
      use "iamcco/markdown-preview.nvim"
      -- markdown 粘贴
      use "ferrine/md-img-paste.vim"
      -- complete
      use "hrsh7th/nvim-compe"
      -- dictory
      use "scrooloose/nerdtree"
      -- latex
      use {
        "lervag/vimtex",
        opt = true,
        config = function()
          vim.g.vimtex_view_general_viewer = "zathura"
          vim.g.vimtex_compiler_latexmk_engines = {
            _ = "-xelatex"
          }
          vim.g.tex_comment_nospell = 1
          vim.g.vimtex_compiler_progname = "nvr"
          vim.g.vimtex_view_general_options = [[--unique file:@pdf\#src:@line@tex]]
          vim.g.vimtex_view_general_options_latexmk = "--unique"
        end,
        ft = "tex"
      }
      use {
        "L3MON4D3/LuaSnip",
        requires = {
          "saadparwaiz1/cmp_luasnip", -- Snippets source for nvim-cmp
          "rafamadriz/friendly-snippets" -- 代码段合集
        }
      }
    end,
    config = {
      max_jobs = 16,
      git = {
        default_url_format = "https://hub.fastgit.org/%s"
      },
      display = {
        open_fn = function()
          return require("packer.util").float({border = "single"})
        end
      }
    }
  }
)
